<?php
class ExtLb_Controller_Helper_Acl {
	public   $acl;
	
	public function __construct(){
		$this->acl = new Zend_Acl();
		
		$this->setRoles();
		$this->setResources();
		$this->setPrivilages();
		$this->setAcl();
	}
	
	private  function setRoles(){
		$this->acl->addRole(new Zend_Acl_Role('poster'));
		$this->acl->addRole(new Zend_Acl_Role('admin'));
		$this->acl->addRole(new Zend_Acl_Role('guest'));
	}
	
	private  function setResources(){
		//
		//PHAN QUYEN THEO CONTROLLER
		$this->acl->addResource(new Zend_Acl_Resource('post')); //post is controller
		$this->acl->addResource(new Zend_Acl_Resource('user'));
		$this->acl->addResource(new Zend_Acl_Resource('index'));
		$this->acl->addResource(new Zend_Acl_Resource('login'));
		$this->acl->addResource(new Zend_Acl_Resource('register'));
		$this->acl->addResource(new Zend_Acl_Resource('comment'));
		$this->acl->addResource(new Zend_Acl_Resource('menu2'));
		$this->acl->addResource(new Zend_Acl_Resource('locationrent'));
		
	}
	
	private  function setPrivilages(){
		//
		$this->acl->allow('poster','post',array('index','edit','delete','add','viewtrash'));//has access to all controller list action
		$this->acl->allow('poster','user',array('edit','info'));
		$this->acl->allow('admin');
		
		$this->acl->deny('poster','user', array('add','index'));
	} 
	
	private function setAcl(){
		Zend_Registry::set('acl', $this->acl);
	}
	
}